using System;
using System.Collections.Generic;
using System.Text;

namespace Mud.Common
{
	public class StopFlag
	{

		public bool IsSet {
			get {
				return _isSet; 
			}
		}
		private bool _isSet;

		public void SetFlag(bool set) {
			lock (this) {
				if (this._isSet != set) {
					_isSet = set;
					if (_stopFlagSetImplementation != null)
						_stopFlagSetImplementation(this, EventArgs.Empty);
				}
			}
		}

		private event EventHandler _stopFlagSetImplementation;


		public event EventHandler StopFlagSet {
			add {
				lock (this) {
					_stopFlagSetImplementation += value;
				}
			}
			remove {
				lock (this) {
					_stopFlagSetImplementation -= value;
				}
			}
		}
	}
}
